package com.khh.dao;

import com.khh.entity.Address;
import com.khh.mapper.AddressMapper;
import com.khh.mybatis.MybatisHelp;
import org.apache.ibatis.session.SqlSession;


/**
 * Created by webrx on 2017-08-31.
 */
public class AddressDao implements AddressMapper{

    private SqlSession ss = new MybatisHelp().getSs();
    private AddressMapper ad;

    public AddressDao() {
        this.ad = ss.getMapper(AddressMapper.class);
    }

    @Override
    public int deleteByPrimaryKey(Integer aid) {
        int n = this.ad.deleteByPrimaryKey(aid);
        ss.commit();
        ss.close();
        return n;
    }

    @Override
    public int insert(Address record) {
        int n = this.ad.insert(record);
        ss.commit();
        ss.close();
        return n;
    }

    @Override
    public int insertSelective(Address record) {
        int n = this.ad.insertSelective(record);
        ss.commit();
        ss.close();
        return n;
    }

    @Override
    public Address selectByPrimaryKey(Integer aid) {
        Address aa = this.ad.selectByPrimaryKey(aid);
        return aa;
    }

    @Override
    public int updateByPrimaryKeySelective(Address record) {
        int n = this.ad.updateByPrimaryKeySelective(record);
        ss.commit();
        ss.close();
        return n;
    }

    @Override
    public int updateByPrimaryKey(Address record) {
        int n = this.ad.updateByPrimaryKey(record);
        ss.commit();
        ss.close();
        return n;
    }
}
